package com.store.controller;

import com.store.domain.R;
import com.store.service.ShopcarService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author yu
 * @date 2024/6/26
 */
@RestController
@RequestMapping("shopCar")
public class ShopCarController {
    @Resource
    private ShopcarService shopcarService;
    /**
     * 加入购物车
     */
    @PutMapping("add/{id}/{num}")
    public R addShopCar(@PathVariable("id") Integer bookId, @PathVariable("num") Integer number) {
        return shopcarService.addShopCar(bookId, number);
    }
    @GetMapping
    public R getUserShopCar() {
        return shopcarService.getUserShopCar();
    }
    @PutMapping("{id}/{num}")
    public R updateShopCar(@PathVariable Integer id, @PathVariable Integer num) {
        return shopcarService.updateShopCar(id, num);
    }
    @DeleteMapping("{ids}")
    public R deleteShopCar(@PathVariable Integer[] ids) {
        return shopcarService.deleteShopCars(ids);
    }
}
